#coding=utf-8

import epics
import tornado
from controller.BaseHandler import BaseHandler
from controller import cagetDouble

class Handler(BaseHandler):

    @tornado.web.asynchronous
    @tornado.gen.coroutine
    def get(self):
        # 返回内容
        self.tplAssigns['boolValues'] = []
        HEGB_PS01_LO = yield self.backend.submit(epics.caget, 'EXP_TB_HV:ASS:HEGB_PS01_LO:SW:bi')
        self.tplAssigns['boolValues'].append(['氦气欠压报警01', HEGB_PS01_LO, 'SW'])
        HEGB_PS02_LO = yield self.backend.submit(epics.caget, 'EXP_TB_HV:ASS:HEGB_PS02_LO:SW:bi')
        self.tplAssigns['boolValues'].append(['氦气欠压报警02', HEGB_PS02_LO, 'SW'])

        self.tplAssigns['doubleValues'] = []

        TC_07 = yield self.backend.submit(cagetDouble, 'EXP_TB_MR:TM:TC_07:TMP:ai')
        self.tplAssigns['doubleValues'].append(['氦容器温度07', TC_07,  '°C'])
        TC_08 = yield self.backend.submit(cagetDouble, 'EXP_TB_MR:TM:TC_08:TMP:ai')
        self.tplAssigns['doubleValues'].append(['氦容器温度08', TC_08,  '°C'])
        TC_09 = yield self.backend.submit(cagetDouble, 'EXP_TB_MR:TM:TC_09:TMP:ai')
        self.tplAssigns['doubleValues'].append(['氦容器温度09', TC_09,  '°C'])
        TC_10 = yield self.backend.submit(cagetDouble, 'EXP_TB_MR:TM:TC_10:TMP:ai')
        self.tplAssigns['doubleValues'].append(['氦容器温度10', TC_10,  '°C'])
        TC_11 = yield self.backend.submit(cagetDouble, 'EXP_TB_MR:TM:TC_11:TMP:ai')
        self.tplAssigns['doubleValues'].append(['氦容器温度11', TC_11,  '°C'])
        TC_12 = yield self.backend.submit(cagetDouble, 'EXP_TB_MR:TM:TC_12:TMP:ai')
        self.tplAssigns['doubleValues'].append(['氦容器温度12', TC_12,  '°C'])
        TC_13 = yield self.backend.submit(cagetDouble, 'EXP_TB_MR:TM:TC_13:TMP:ai')
        self.tplAssigns['doubleValues'].append(['氦容器温度13', TC_13,  '°C'])
        TC_14 = yield self.backend.submit(cagetDouble, 'EXP_TB_MR:TM:TC_14:TMP:ai')
        self.tplAssigns['doubleValues'].append(['氦容器温度14', TC_14,  '°C'])
        TC_15 = yield self.backend.submit(cagetDouble, 'EXP_TB_MR:TM:TC_15:TMP:ai')
        self.tplAssigns['doubleValues'].append(['氦容器温度15', TC_15,  '°C'])
        TC_16 = yield self.backend.submit(cagetDouble, 'EXP_TB_MR:TM:TC_16:TMP:ai')
        self.tplAssigns['doubleValues'].append(['氦容器温度16', TC_16,  '°C'])
        TC_17 = yield self.backend.submit(cagetDouble, 'EXP_TB_MR:TM:TC_17:TMP:ai')
        self.tplAssigns['doubleValues'].append(['氦容器温度17', TC_17,  '°C'])
        TC_18 = yield self.backend.submit(cagetDouble, 'EXP_TB_MR:TM:TC_18:TMP:ai')
        self.tplAssigns['doubleValues'].append(['氦容器温度18', TC_18,  '°C'])
        TC_19 = yield self.backend.submit(cagetDouble, 'EXP_TB_MR:TM:TC_19:TMP:ai')
        self.tplAssigns['doubleValues'].append(['氦容器温度19', TC_19,  '°C'])
        TC_20 = yield self.backend.submit(cagetDouble, 'EXP_TB_MR:TM:TC_20:TMP:ai')
        self.tplAssigns['doubleValues'].append(['氦容器温度20', TC_20,  '°C'])

        OAP_PS03 = yield self.backend.submit(cagetDouble, 'EXP_TB_HV:ASS:OAP_PS03:PRS:ai')
        self.tplAssigns['doubleValues'].append(['氦容器压力PT16', OAP_PS03, 'kPa'])
        IAP_PS02 = yield self.backend.submit(cagetDouble, 'EXP_TB_HV:ASS:IAP_PS02:PRS:ai')
        self.tplAssigns['doubleValues'].append(['氦容器压力PT17', IAP_PS02, 'kPa'])

        OAP_PS02 = yield self.backend.submit(cagetDouble, 'EXP_TB_HV:ASS:OAP_PS02:PRS:ai')
        self.tplAssigns['doubleValues'].append(['氦容器压力', OAP_PS02, 'kPa'])
        HED_PS03 = yield self.backend.submit(cagetDouble, 'EXP_TB_HV:ASS:HED_PS03:PRS:ai')
        self.tplAssigns['doubleValues'].append(['缓冲罐压力', HED_PS03, 'MPa'])

        LCS2FT03 = yield self.backend.submit(cagetDouble, 'EXP_TB_EU:LCS2:LCS2FT03:FLW:ai')
        self.tplAssigns['doubleValues'].append(['下部外反射体流量', LCS2FT03, 'm³/h'])
        LCS2FT02 = yield self.backend.submit(cagetDouble, 'EXP_TB_EU:LCS2:LCS2FT02:FLW:ai')
        self.tplAssigns['doubleValues'].append(['束道水冷部冷却水流量', LCS2FT02, 'm³/h'])

        self.render("ezca/container.html", **self.tplAssigns)
